package com.jianganming.observer.demo;

import java.util.ArrayList;
import java.util.List;

//自定义广播抽象类
public abstract class Subject {

    private String name;

    public Subject(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    protected List<Observer> observers = new ArrayList<>();

    public void add(Observer observer){
        observers.add(observer);
    }

    public void remove(Observer observer){
        observers.remove(observer);
    }

    public abstract void notifyObserver(Subject subject); //通知观察者方法
}
